﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ChinaGS.Lian.ModuleRemoting;

public partial class recharge_area_fill_netcom : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SysCommon.checkUserLogin();

        if (!IsPostBack)
        {           
            String ReceiPay = Request["HidReceiPay"];
            String cusNo = Request["HidcusNo"];
            String AcctId = Request["HidAcctId"];
            String Charge = Request["HidCharge"];

            if (ReceiPay != null)
            {
               
                    //显示查询结果     
                    this.LabReceiPayName.Text = "本期账单";
                    this.LabReceiPay.Text = ReceiPay;         
                    this.LabChargeName.Text = "账户余额";
                    this.LabCharge.Text = Charge;                
                
                    HidCharge.Value = Charge;
                    HidReceiPay.Value = ReceiPay;
                    HidcusNo.Value = cusNo;
                    HidAcctId.Value = AcctId;

                    PanPay.Visible = true;

            }
            else
            {
                PanPay.Visible = false;
                this.LabMessage.Text = "操作失败，请重试！";

            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Double Charge = System.Convert.ToDouble(HidCharge.Value);
        String cusNo = HidcusNo.Value;       
        Double ReceiPay = System.Convert.ToDouble(HidReceiPay.Value);
        String AcctId = HidAcctId.Value;

        //充值前操作            
        int user_paid_id = DataBaseOperate_SQLServer.execPPaidAtonce(Session["user_id"].ToString(), "2".ToString(), HidcusNo.Value, 
            TexPayMoney.Text, TexPayMoney.Text, "0".ToString(), "0".ToString(), "0".ToString(), System.DateTime.Now.ToString(), "none".ToString());
        if (user_paid_id < 0)
        {
            LabMessage.Text = "操作失败！原因是：" + RemotingClass.alertExecErroeResult(user_paid_id).ToString() + "，请重试";
            PanPay.Visible = false;
        }
        else {
            NetComPackage ncp = RemotingClass.netComPayMoney(AcctId, cusNo, System.Convert.ToDouble(TexPayMoney.Text), Charge);

            //测试使用
            /*NetComPackage ncp = new NetComPackage();
            ncp.SerialNo = "1234567890";
            ncp.Status = true;
            ncp.StatusNo = "00";
            ncp.Message = "success";
            ncp.Charge = 0;
            ncp.CusName = "denveryee";
            ncp.ItemNo = "123456789";
            ncp.PayDate = DateTime.Now.ToString("yyyy年MM月dd日");
            ncp.RealPay = 0;
            ncp.ReceiPay = 100;
            ncp.CusNo = HidcusNo.Value;*/

            if (ncp.Status)
            {
                //充值成功操作                
                DataBaseOperate_SQLServer.execPPaidSetStatus(user_paid_id.ToString(), ncp.SerialNo,
                    ncp.CusNo, ncp.Message, "1".ToString(), SysCommon.getClientIP(), "0".ToString());
                Response.Redirect("paysuccess_netcom.aspx?HidRealPay=" + ncp.RealPay
                                    + "&HidCharge=" + ncp.Charge.ToString()
                                    + "&HidReceiPay=" + ncp.ReceiPay.ToString()
                                    + "&HidPayDate=" + ncp.PayDate
                                    + "&HidcusNo=" + ncp.CusNo);
            }
            else
            {
                DataBaseOperate_SQLServer.execPPaidSetStatus(user_paid_id.ToString(), ncp.SerialNo,
                    ncp.CusNo, ncp.Message, "2".ToString(), SysCommon.getClientIP(), "0".ToString());
                LabMessage.Text = "操作失败！原因是：" + ncp.Message + "，请稍后重试";
                PanPay.Visible = false;
            }
        
        }       

    }
}
